#pragma once
//class _ZTP_EXT_CLASS ZCString
//{
//public:
//	//typedef std::basic_string<char>		stdchar;
//	ZCString(void);
//	virtual~ZCString(void);
//
//	ZCString( CString lpStr );
//	ZCString( char  * lpStr );
//	ZCString( WCHAR * lpStr );
//
//
//	void operator =( CString	lpStr );
//	void operator =( char	*	lpStr );
//	void operator =( WCHAR	*	lpStr );
//	char * GetChar();
//	WCHAR* GetWChar();
//private:
//	CString m_data;	
//};

 
class ZNCharW;
class _ZTP_EXT_CLASS ZNCharA
{
public:
	ZNCharA(void){creatnull();}
	~ZNCharA(void){CLear();}
	
	ZNCharA(char * data)			{ creatnull(); change(data);}
	ZNCharA(wchar_t * data)			{ creatnull(); change(data);}
	ZNCharA(const char * data)		{ creatnull(); change(data);}
	ZNCharA(const wchar_t * data)	{ creatnull(); change(data);}
	ZNCharA(ZNCharA & data)	{ creatnull(); change(data.Buf());}
	ZNCharA(ZNCharW & data);//	{ creatnull(); change(data.Buf());}


	ZNCharA(CString data)	{ creatnull(); change(data.GetBuffer());}
	operator CString ()				{return CString( m_buf);}
	ZNCharA& operator =( CString data ) {change(data.GetBuffer()); return (*this);}


	
	operator char* ()				{return m_buf;}
	operator const char* ()			{return m_buf;}
	

	
	ZNCharA& operator =( ZNCharA data ) {change(data.Buf()); return (*this);}
	ZNCharA& ZNCharA::operator =( ZNCharW data );
	ZNCharA& operator =( const	wchar_t * data ) {change(data); return (*this);}
	ZNCharA& operator =(		wchar_t * data ) {change(data); return (*this);}
	ZNCharA& operator =( const	char    * data ) {change(data); return (*this);}
	ZNCharA& operator =(		char    * data ) {change(data); return (*this);}


	char* Buf()				{return m_buf;}
	int GetLen(){return m_len;}
protected:

	void change(const char * data);
	void change(const wchar_t * data);
	void change(char * data);
	void change(wchar_t * data);

	char * m_buf;
	int m_len;
	void creatnull (){ m_buf = NULL;m_len = 0;}
	void CLear();
};


class _ZTP_EXT_CLASS ZNCharW
{
public:
	ZNCharW(void){creatnull();}
	~ZNCharW(void){CLear();}

	ZNCharW(char * data)			{ creatnull(); change(data);}
	ZNCharW(wchar_t * data)			{ creatnull(); change(data);}
	ZNCharW(const char * data)		{ creatnull(); change(data);}
	ZNCharW(const wchar_t * data)	{ creatnull(); change(data);}
	ZNCharW(ZNCharW & data)	{ creatnull(); change(data.Buf());}
	ZNCharW(ZNCharA & data)	{ creatnull(); change(data.Buf());}


	ZNCharW(CString data)	{ creatnull(); change(data.GetBuffer());}
	operator CString ()				{return CString( m_buf);}
	ZNCharW& operator =( CString data ) {change(data.GetBuffer()); return (*this);}


	operator wchar_t* ()				{return m_buf;}
	operator const wchar_t* ()			{return m_buf;}

	

	

	ZNCharW& operator =( ZNCharA data ){change(data.Buf()); return (*this);}
	
	ZNCharW& operator =( ZNCharW data ) {change(data.Buf()); return (*this);}
	ZNCharW& operator =( const	wchar_t * data ) {change(data); return (*this);}
	ZNCharW& operator =(		wchar_t * data ) {change(data); return (*this);}
	ZNCharW& operator =( const	char    * data ) {change(data); return (*this);}
	ZNCharW& operator =(		char    * data ) {change(data); return (*this);}


	wchar_t* Buf()				{return m_buf;}
	int GetLen(){return m_len;}
protected:

	void change(const char * data);
	void change(const wchar_t * data);
	void change(char * data);
	void change(wchar_t * data);

	wchar_t * m_buf;
	int m_len;
	void creatnull (){ m_buf = NULL;m_len = 0;}
	void CLear();
};
